<?php
header("content-type:text/html;charset=utf-8;");


$con = mysqli_connect(
    "127.0.0.1",
    "root",
    "310831",
    'fatie'
);



$limit = $_POST['limit'];
$page = $_POST['page'];
$new_page = ($page - 1) * $limit;


$sql = "select * from demo01 order by id desc limit " . $new_page . "," . $limit;


$result = $con->query($sql);


$sql2 = 'select * from demo01';


$count = mysqli_num_rows($con->query($sql2));


$arr = array();
while ($row = mysqli_fetch_array($result)) {
    $arr[] = $row;
}
$donation_data = array(  // 拼装成为前端需要的JSON
    'code' => 0,
    'msg' => '',
    'count' => $count,
    'data' => $arr
);
echo json_encode($donation_data);



